var user1={name:'john',age:100};
var user2={name:'alice',age:120};
var user3={name:'bone',age:111};
function createComparitionFunction(prop){
	return function(o1,o2){
		var v1=o1[prop];
		var v2=o2[prop];
		if(v1>v2) return 1;
		else if(v1==v2) return 0;
		else return -1;
	}
}
var nameCompare=createComparitionFunction("name");
var ageCompare=createComparitionFunction("age");
var rs1=nameCompare(user1,user2);
var rs2=ageCompare(user1,user2);
console.log(rs1+"...."+rs2);

var us=[user1,user2,user3];
us.sort(ageCompare);
us.forEach(function(u){
	console.log(u.name+"...."+u.age);
})




